//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.jpgolay.me.order;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import javax.swing.*;
import org.jpgolay.gui.fixed.LabelAndTextField;
import org.jpgolay.gui.fixed.TwoButton;

public class ShippingOrderGUI extends JInternalFrame {

    public ShippingOrderGUI() {
        jContentPane = null;
        jPanel = null;
        sum = null;
        twoButton = null;
        initialize();
    }

    private void initialize() {
        setSize(350, 100);
        setContentPane(getJContentPane());
        setFrameIcon(new ImageIcon(getClass().getResource("/org/jpgolay/me/images/pieces18x18.png")));
        setTitle("Frais de Port");
    }

    private JPanel getJContentPane() {
        if (jContentPane == null) {
            jContentPane = new JPanel();
            jContentPane.setLayout(new BorderLayout());
            jContentPane.add(getJPanel(), "Center");
        }
        return jContentPane;
    }

    private JPanel getJPanel() {
        if (jPanel == null) {
            GridLayout gridLayout1 = new GridLayout();
            jPanel = new JPanel();
            jPanel.setLayout(gridLayout1);
            gridLayout1.setRows(2);
            gridLayout1.setColumns(1);
            jPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
            jPanel.add(getSumPanel(), null);
            jPanel.add(getButtonPanel(), null);
        }
        return jPanel;
    }

    private LabelAndTextField getSumPanel() {
        if (sum == null) {
            sum = new LabelAndTextField();
            sum.setLabel("Montant (HT)");
            sum.setToolTipText("Utilise toujours la TVA 1");
            sum.setVal("0.00");
        }
        return sum;
    }

    private TwoButton getButtonPanel() {
        if (twoButton == null) {
            twoButton = new TwoButton();
            twoButton.setButtonLabelLeft("VALIDER");
            twoButton.setButtonLabelRight("ANNULER");
        }
        return twoButton;
    }

    public void setSumValue(String value) {
        getSumPanel().setVal(value);
    }

    public String getSumValue() {
        return getSumPanel().getVal();
    }

    public JButton getOKButton() {
        return getButtonPanel().getButtonLeft();
    }

    public JButton getCANCELButton() {
        return getButtonPanel().getButtonRight();
    }
    private JPanel jContentPane;
    private JPanel jPanel;
    private LabelAndTextField sum;
    private TwoButton twoButton;
}
